package com.kingyea.app.market.appExtendInfo.controller;

import com.kingyea.app.market.appExtendInfo.bean.AppExtendInfo;
import com.kingyea.app.market.appExtendInfo.service.AppExtendInfoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author
 * @version v1.0.0
 * @description AppExtendInfo 控制层
 * @date Created in 2018-02-10 16:11:07
 */
@RequestMapping(value = "/appExtendInfo")
@RestController
public class AppExtendInfoController {

    private static final Logger LOGGER = LoggerFactory.getLogger(AppExtendInfoController.class);

    @Autowired
    private AppExtendInfoService appExtendInfoService;

    /**
     * 查询全部
     *
     * @param
     * @return
     */
    @RequestMapping(method = RequestMethod.POST)
    public Object list(AppExtendInfo appExtendInfo) throws Exception {
        return appExtendInfoService.list(appExtendInfo);
    }

    /**
     * 通过ID查找对象
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "/{id}", method = RequestMethod.POST)
    public AppExtendInfo detail(@PathVariable String id) throws Exception {
        return appExtendInfoService.getById(id);
    }

    /**
     * 创建
     *
     * @param appExtendInfo
     * @return
     */
    @RequestMapping(value = "/create", method = RequestMethod.POST)
    public AppExtendInfo create(@RequestBody AppExtendInfo appExtendInfo) throws Exception {
        return appExtendInfoService.save(appExtendInfo);
    }

    /**
     * 更新
     *
     * @param appExtendInfo
     * @return
     */
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public AppExtendInfo update(@RequestBody AppExtendInfo appExtendInfo) throws Exception {
        return appExtendInfoService.update(appExtendInfo);
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
    public int delete(@PathVariable String id) throws Exception {
        return appExtendInfoService.deleteById(id);
    }

    @RequestMapping(value = "/test/{appExtendInfo}", method = RequestMethod.POST)
    public void test(@RequestBody AppExtendInfo appExtendInfo) {
        try {

            appExtendInfoService.test(appExtendInfo);
        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
        }
    }

    public AppExtendInfo getByAppCode(@PathVariable String code) throws Exception {
        return appExtendInfoService.getByAppCode(code);

    }
}
